import Vue from 'vue'
import VueRouter from 'vue-router'
import UserHome from '../views/users/index'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/users'
  },
  {
    path: '/users',
    component: UserHome,
    children: [
      {
        path: '/',
        redirect: 'list'
      },
      {
        path: 'update',
        redirect: 'list'
      },
      {
        path: 'list',
        component: () => import('../views/users/list')
      },
      {
        path: 'add',
        name: 'addUser',
        component: () => import('../views/users/add')
      },
      {
        path: 'update/:id',
        name: 'updateUser',
        component: () => import('../views/users/update')
      }
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
